package vo;

import java.util.List;

import logic.utility_logic.NoSuchElementException;
import po.StuCouScoRecPO;

public class CouStuScoListVO {
	
	private CourseVO courseVO;
	private List<StuCouScoRecPO> stuScoList;
	private List<StudentVO> studentList;
	
	public CouStuScoListVO(CourseVO courseVO, List<StuCouScoRecPO> stuScoList,
			List<StudentVO> studentList) {
		super();
		this.courseVO = courseVO;
		this.stuScoList = stuScoList;
		this.studentList = studentList;
	}
	public CourseVO getCourseVO() {
		return courseVO;
	}
	public List<StudentVO> getAllStudents(){
		return studentList;
	}
	public int getScore(String studentID){
		for(StuCouScoRecPO rec : stuScoList){
			if(rec.getStudentID().equals(studentID)){
				return rec.getScore();
			}
		}
		throw new NoSuchElementException();
	}
	@Override
	public String toString() {
		return "CouStuScoListVO [courseVO=" + courseVO + ", stuScoList="
				+ stuScoList + ", studentList=" + studentList + "]";
	}
	
	public String[][] toDyadicArray(){
		String[][] array = null;
		int i=0;
		for(StuCouScoRecPO scs : stuScoList){
			array[i][0] = scs.getStudentID();
			array[i][1] = ""+scs.getScore();
			i++;
		}
		return array;
	}
	
	public String[][] stuListToDyadicArray(){
		String[][] array = null;
		int i=0;
		for(StudentVO s : studentList){
			array[i][0] = s.getStudentID();
			array[i][1] = ""+s.getName();
			i++;
		}
		return array;
	}
}
